package g

import (
	"reflect"
	"testing"
)

func GetNode(vals []int) *ListNode {
	head := &ListNode{}
	p := head
	for i := 0; i < len(vals); i++ {
		p.Next = &ListNode{vals[i], nil}
		p = p.Next
	}
	return head.Next
}

func Test_deleteDuplicates(t *testing.T) {
	type args struct {
		head *ListNode
	}
	tests := []struct {
		name string
		args args
		want *ListNode
	}{
		{"1", args{nil}, nil},
		{"2", args{GetNode([]int{1, 1, 2})}, GetNode([]int{1, 2})},
		{"3", args{GetNode([]int{1, 1, 2, 3, 3})}, GetNode([]int{1, 2, 3})},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := deleteDuplicates(tt.args.head); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("deleteDuplicates() = %v, want %v", got, tt.want)
			}
		})
	}
}
